<!--
wy 商家信息页面
描述：显示商家信息
最后修改时间：9.16/14:9
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>吃游网-商家信息</title>
    <!-- ALL STYLESHEET -->
    <link rel="stylesheet" href="css/quote/bootstrap.css">
    <link rel="stylesheet" href="css/mystyle.css">
    <link rel="stylesheet" href="css/store.css">

    <link rel="stylesheet" href="css/head.css">
    <link rel="stylesheet" href="css/footer.css">
    <script src="js/quote/jquery-3.4.1.js"></script>
    <script src="js/quote/hf.js"></script>

    <script src="js/quote/jquery.js"></script>
    <script src="js/quote/bootstrap.js"></script>
    <script src="js/custom.js"></script>

</head>
<body>


<div class="page-content background">
    <!-- desktop bar -->
    <div class="container">
        <div class="">
            <h3 style="margin: 22px 0">商家信息</h3>
        </div>
    </div>


    <section class="desk-com " style="padding-top: 0;padding-bottom: 0">
        <div class="container">
            <div class="row">
                <div class="col-sm-5">
                    <div id="pro-img" class="carousel slide" data-ride="carousel" style="margin-top: 14px">
                        <div class="carousel-inner" id="img" role="listbox">
                            <div class="item active" id="img1"><!--<img src="https://img.meituan.net/msmerchant/ca2babddac3d1092b4d1274a6f82a483156638.jpg@600w_600h_1l"
                                    alt="">--></div>
                            <!--                            <div class="item"><img
                                                                src="https://img.meituan.net/msmerchant/32680c2fd718a844e48415f25cb0fdfd1750462.jpg@600w_600h_1l"
                                                                alt=""></div>
                                                        <div class="item"><img
                                                                src="https://img.meituan.net/msmerchant/24fa30951898469ba67f1d24979987f02116215.jpg@600w_600h_1l"
                                                                alt=""></div>-->
                        </div>
                        <!--                        <a class="left carousel-control" href="#pro-img" role="button" data-slide="prev"><i
                                                        class="fa fa-angle-left"></i></a>
                                                <a class="right carousel-control" href="#pro-img" role="button" data-slide="next"><i
                                                        class="fa fa-angle-right"></i></a>-->
                    </div>
                </div>
                <div class="col-sm-7">
                    <div class="d-left" style="margin: 30px">
                        <div class="name" style="margin-bottom: 10px">
                            <!-- react-text: 26 -->宽城子成都市井火锅（观前总店）<!-- /react-text --></div>
                        <hr/>
                        <div class="score clear">

                            <p id="score">3.4分</p></div>
                        <div class="address"><p id="storelocation">地址：姑苏区碧凤坊观前街245号（韩国购物城1楼）<b></b></p>
                            <p id="phone">电话：19941852689</p>
                            <p id="time"><!--营业时间：周一至周日 11:30-24:00
                                2019-06-21 11:30-20:00--></p>


                            <ul class="list-inline wish-email">
                                <li class="addbutton1"><i class="fa fa-heart-o "></i>
                                    <a href="#" class="addbutton" onclick="addshopcoll(getQueryVariable())">收藏该商家</a>
                                </li>
                            </ul>

                            <p class="tags" id="tag">
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section class="desk-com" style="padding-top: 15px">
        <div class="container">
            <div class="row">
                <div class="col-sm-12">
                    <div class="description">
                        <!-- Tab panes -->
                        <div class="tab-content" style="margin-top: 15px">
                            <div role="tabpanel" class="tab-pane active" id="description">
                                <h1><span class="t-color-1">推荐</span> 美食</h1>
                                <section class="featured-product">
                                    <div class="container">
                                        <div id="related-pro" class="carousel slide" data-ride="carousel">
                                            <!--                                            <ol class="carousel-indicators">
                                                                                            <li data-target="#related-pro" data-slide-to="0" class="active"><i
                                                                                                    class="fa fa-angle-left"></i></li>
                                                                                            <li data-target="#related-pro" data-slide-to="1"><i
                                                                                                    class="fa fa-angle-right"></i></li>
                                                                                        </ol>-->
                                            <div class="carousel-inner" role="listbox">
                                                <div class="item active">
                                                    <div class="row" id="commoditylist">
                                                        <!--这里是展示商品-->
                                                        <!--<div class="col-sm-3">
                                                            <div class="thumbnail">
                                                                &lt;!&ndash;span class="e-label"><div>Sale</div></span&ndash;&gt;
                                                                <span class="service-link text-center">
                                                                    <img class="img-responsive"
                                                                         src="https://img.meituan.net/msmerchant/11edaa318030a182e861eb4e56d10a142606510.jpg@600w_600h_1l"
                                                                         alt="">

                                                                </span>
                                                                <div class="caption">
                                                                    <div class="category"> 油炸小鱼干
                                                                        <div class="pull-right">
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star-o"></i>
                                                                        </div>
                                                                    </div>
                                                                    <h3>菜品实在是太丰盛的，3人根本消化不了，那个鸡汤就直接打包了。真的是担心老板能赚钱吗？</h3>
                                                                    <strong>￥54</strong>
                                                                    <div class="addtocar"><a href="#"
                                                                                             class="btn btn-default"
                                                                                             role="button">添加到购物车</a><span
                                                                            class="pull-right "><i
                                                                            class="fa fa-heart-o "></i>
                                                                        <a href="#" class="collection">添加到收藏</a></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="thumbnail">
                                                                <span class="service-link text-center">
                                                                    <img class="img-responsive"
                                                                         src="https://img.meituan.net/msmerchant/11edaa318030a182e861eb4e56d10a142606510.jpg@600w_600h_1l"
                                                                         alt="">

                                                                </span>
                                                                <div class="caption">
                                                                    <div class="category"> 油炸小鱼干
                                                                        <div class="pull-right">
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star-o"></i>
                                                                        </div>
                                                                    </div>
                                                                    <h3>菜品实在是太丰盛的，3人根本消化不了，那个鸡汤就直接打包了。真的是担心老板能赚钱吗？</h3>
                                                                    <strong>￥54</strong>
                                                                    <div><a href="#" class="btn btn-default"
                                                                            role="button">添加到购物车</a><span
                                                                            class="pull-right"><i
                                                                            class="fa fa-heart-o"></i> <a href="#"
                                                                                                          class="collection">添加到收藏</a></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="thumbnail">
                                                                <span class="service-link text-center">
                                                                    <img class="img-responsive"
                                                                         src="https://img.meituan.net/msmerchant/11edaa318030a182e861eb4e56d10a142606510.jpg@600w_600h_1l"
                                                                         alt="">

                                                                </span>
                                                                <div class="caption">
                                                                    <div class="category"> 油炸小鱼干
                                                                        <div class="pull-right">
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star-o"></i>
                                                                        </div>
                                                                    </div>
                                                                    <h3>菜品实在是太丰盛的，3人根本消化不了，那个鸡汤就直接打包了。真的是担心老板能赚钱吗？</h3>
                                                                    <strong>￥54</strong>
                                                                    <div><a href="#" class="btn btn-default"
                                                                            role="button">添加到购物车</a><span
                                                                            class="pull-right"><i
                                                                            class="fa fa-heart-o"></i> <a href="#"
                                                                                                          class="collection">添加到收藏</a></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="thumbnail">
                                                                <span class="service-link text-center">
                                                                    <img class="img-responsive"
                                                                         src="https://img.meituan.net/msmerchant/11edaa318030a182e861eb4e56d10a142606510.jpg@600w_600h_1l"
                                                                         alt="">

                                                                </span>
                                                                <div class="caption">
                                                                    <div class="category"> 油炸小鱼干
                                                                        <div class="pull-right">
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star-o"></i>
                                                                        </div>
                                                                    </div>
                                                                    <h3>菜品实在是太丰盛的，3人根本消化不了，那个鸡汤就直接打包了。真的是担心老板能赚钱吗？</h3>
                                                                    <strong>￥54</strong>
                                                                    <div><a href="#" class="btn btn-default"
                                                                            role="button">添加到购物车</a><span
                                                                            class="pull-right"><i
                                                                            class="fa fa-heart-o"></i> <a href="#"
                                                                                                          class="collection">添加到收藏</a></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>-->
                                                    </div>
                                                </div>
                                                <!--<div class="item">
                                                    <div class="row">
                                                        <div class="col-sm-3">
                                                            <div class="thumbnail">
                                                                &lt;!&ndash;span class="e-label"><div>Sale</div></span&ndash;&gt;
                                                                <span class="service-link text-center">
                                                                    <img class="img-responsive"
                                                                         src="https://img.meituan.net/msmerchant/11edaa318030a182e861eb4e56d10a142606510.jpg@600w_600h_1l"
                                                                         alt="">

                                                                </span>
                                                                <div class="caption">
                                                                    <div class="category"> 油炸小鱼干
                                                                        <div class="pull-right">
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star-o"></i>
                                                                        </div>
                                                                    </div>
                                                                    <h3>菜品实在是太丰盛的，3人根本消化不了，那个鸡汤就直接打包了。真的是担心老板能赚钱吗？</h3>
                                                                    <strong>￥54</strong>
                                                                    <div><a href="#" class="btn btn-default"
                                                                            role="button">添加到购物车</a><span
                                                                            class="pull-right"><i
                                                                            class="fa fa-heart-o"></i> <a href="#"
                                                                                                          class="collection">添加到收藏</a></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="thumbnail">
                                                                <span class="service-link text-center">
                                                                    <img class="img-responsive"
                                                                         src="https://img.meituan.net/msmerchant/11edaa318030a182e861eb4e56d10a142606510.jpg@600w_600h_1l"
                                                                         alt="">

                                                                </span>
                                                                <div class="caption">
                                                                    <div class="category"> 油炸小鱼干
                                                                        <div class="pull-right">
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star-o"></i>
                                                                        </div>
                                                                    </div>
                                                                    <h3>菜品实在是太丰盛的，3人根本消化不了，那个鸡汤就直接打包了。真的是担心老板能赚钱吗？</h3>
                                                                    <strong>￥54</strong>
                                                                    <div><a href="#" class="btn btn-default"
                                                                            role="button">添加到购物车</a><span
                                                                            class="pull-right"><i
                                                                            class="fa fa-heart-o"></i> <a href="#"
                                                                                                          class="collection">添加到收藏</a></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="thumbnail">
                                                                <span class="service-link text-center">
                                                                    <img class="img-responsive"
                                                                         src="https://img.meituan.net/msmerchant/11edaa318030a182e861eb4e56d10a142606510.jpg@600w_600h_1l"
                                                                         alt="">

                                                                </span>
                                                                <div class="caption">
                                                                    <div class="category"> 油炸小鱼干
                                                                        <div class="pull-right">
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star-o"></i>
                                                                        </div>
                                                                    </div>
                                                                    <h3>菜品实在是太丰盛的，3人根本消化不了，那个鸡汤就直接打包了。真的是担心老板能赚钱吗？</h3>
                                                                    <strong>￥54</strong>
                                                                    <div><a href="#" class="btn btn-default"
                                                                            role="button">添加到购物车</a><span
                                                                            class="pull-right"><i
                                                                            class="fa fa-heart-o"></i> <a href="#"
                                                                                                          class="collection">添加到收藏</a></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="thumbnail">
                                                                <span class="service-link text-center">
                                                                    <img class="img-responsive"
                                                                         src="https://img.meituan.net/msmerchant/11edaa318030a182e861eb4e56d10a142606510.jpg@600w_600h_1l"
                                                                         alt="">

                                                                </span>
                                                                <div class="caption">
                                                                    <div class="category"> 油炸小鱼干
                                                                        <div class="pull-right">
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star"></i>
                                                                            <i class="fa fa-star-o"></i>
                                                                        </div>
                                                                    </div>
                                                                    <h3>菜品实在是太丰盛的，3人根本消化不了，那个鸡汤就直接打包了。真的是担心老板能赚钱吗？</h3>
                                                                    <strong>￥54</strong>
                                                                    <div><a href="#" class="btn btn-default"
                                                                            role="button">添加到购物车</a><span
                                                                            class="pull-right"><i
                                                                            class="fa fa-heart-o"></i> 添加到收藏</span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>-->
                                            </div>
                                        </div>
                                    </div>
                                </section>
                            </div>

                        </div>
                        <nav style="text-align: center">
                            <ul class="pagination" id="commpage">

                            </ul>
                        </nav>

                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
</body>
<!--获取商家id-->
<script>
    function getQueryVariable() {
        let query = window.location.search.substring(1);
        let pair = query.split("=");
        return pair[1];
    }
</script>
<!--展示商店信息-->
<script>
    var storeId = getQueryVariable();
    $.ajax({
        url: "/store/findstorebyid",
        data: {"storeId": storeId},
        success: function (data) {
            console.log(data)
            $(".name").html(data.storeName);
            $("#score").html('商家评分：' + data.storeScore + '分');
            $("#storelocation").html('地址：' + data.storeLocation);
            $("#phone").html('电话：' + data.storePhone);
            var firstTime = data.storeBusinessHours;
            var i1 = firstTime.indexOf("T");
            firstTime = firstTime.substr(i1);
            var i2 = firstTime.lastIndexOf(":");
            firstTime = firstTime.substring(1, i2);
            var lastTime = data.storeProofingHours;
            var i3 = lastTime.indexOf("T");
            lastTime = lastTime.substr(i3);
            var i4 = lastTime.lastIndexOf(":");
            lastTime = lastTime.substring(1, i4);
            var time = firstTime + "-" + lastTime;
            $("#time").html('营业时间：' + time);
            $("#img1").html('<img src="' + data.pictureList[0].picture + '" style="width: 457px;height: 310px">');

            var html = '标签：';
            for (var i = 0; i < data.labelList.length; i++) {
                if (i + 1 == data.labelList.length) {
                    html += '<a href="#">' + data.labelList[i].labelName + '</a>'
                }else {
                    html += '<a href="#">' + data.labelList[i].labelName + '</a>，'
                }
            }
            $("#tag").html(html);
        }
    })
</script>
<!--设置分页，获取当前页数并展示商品-->
<script>
    var currPage = 1;
    function changeCurrPage1(page) {
        $('#commoditylist').html('');
        currPage = page;
        var storeId = getQueryVariable();
        //展示商家的商品信息
        $.ajax({
            url: "/store/findcommoditybystoreid",
            dataType: "json",
            data: "storeId=" + storeId + "&currPage=" + currPage,
            success: function (data) {
                $.each(data.dataList, function (i, dom) {
                    $('#commoditylist').append(
                        `
                     <div class="col-sm-3">
                         <div class="thumbnail">
                             <span class="service-link text-center">
                                 <a href="/commodity.html?commodityId=${dom.commodityId}">
                                      <img class="img-responsive" style="height: 153px;width: 230px"
                                      src="${dom.pictureList[0].picture}"></a>
                             </span>
                             <div class="caption">
                                 <a href="/commodity.html?commodityId=${dom.commodityId}"><div class="category"> ${dom.commodityName}
                                 </div></a>
                                 <a href="/commodity.html?commodityId=${dom.commodityId}"><h3 style="max-height: 79px;min-height: 79px;overflow: hidden;">${dom.commodityDescribe}</h3></a>
                                 <strong>￥${dom.commodityPrice}</strong>
                                 <div class="addtocar"><a href="#" onclick="addcart('${dom.commodityId}')"
                                                          class="btn btn-default"
                                                          role="button">添加到购物车</a><span
                                         class="pull-right "><i
                                         class="fa fa-heart-o "></i>
                                     <a href="#" class="collection" onclick="addcoll('${dom.commodityId}')">添加到收藏</a></span>
                                 </div>
                             </div>
                         </div>
                     </div>
                `)
                });
            }
        })
    }
</script>
<!--添加商家到收藏-->
<script>
    function addshopcoll(storeId) {
        var ok = window.confirm("确定要收藏该商家吗")
        if (ok) {
            $.get("user/finduser", {}, function (data) {
                if (data.length > 0) {
                    var user = data;
                    $.ajax({
                        url: "/collection/addtocoll",
                        dataType: "json",
                        data: "userId=" + user + "&storeId=" + storeId,
                        success: function (data) {
                            alert(data.message)
                        }
                    })
                } else {
                    location.href = "error/403.html"
                }
            });
        }
    }
</script>
<!--获取商家id-->
<script>
    function getQueryVariable() {
        let query = window.location.search.substring(1);
        let pair = query.split("=");
        return pair[1];
    }
</script>
<!--展示商家的商品信息-->
<script>
    var storeId = getQueryVariable();
    //展示商家的商品信息
    $.ajax({
        url: "/store/findcommoditybystoreid",
        dataType: "json",
        data: "storeId=" + storeId + "&currPage=1",
        success: function (data) {
            //记录条数
            var total1 = 0;
            total1 = data.totalSize;
            //页数
            var pageNum = Math.ceil(total1 / 8);
            //加载分页插件
            var html = '';
            for (var i = 1; i <= pageNum; i++) {
                html += '<li><a href="javascript:void(0)" onclick="changeCurrPage1(' + i + ')">' + i + '</a></li>';
            }
            $('#commpage').html(html)

            $.each(data.dataList, function (i, dom) {
                $('#commoditylist').append(
                    `
                     <div class="col-sm-3">
                         <div class="thumbnail">
                             <span class="service-link text-center">
                                 <a href="/commodity.html?commodityId=${dom.commodityId}">
                                      <img class="img-responsive" style="height: 153px;width: 230px"
                                      src="${dom.pictureList[0].picture}"></a>
                             </span>
                             <div class="caption">
                                 <a href="/commodity.html?commodityId=${dom.commodityId}"><div class="category"> ${dom.commodityName}
                                 </div></a>
                                 <a href="/commodity.html?commodityId=${dom.commodityId}"><h3 style="max-height: 79px;min-height: 79px;overflow: hidden;">${dom.commodityDescribe}</h3></a>
                                 <strong>￥${dom.commodityPrice}</strong>
                                 <div class="addtocar"><a href="#" onclick="addcart('${dom.commodityId}')"
                                                          class="btn btn-default"
                                                          role="button">添加到购物车</a><span
                                         class="pull-right "><i
                                         class="fa fa-heart-o "></i>
                                     <a href="#" class="collection" onclick="addcoll('${dom.commodityId}')">添加到收藏</a></span>
                                 </div>
                             </div>
                         </div>
                     </div>
                `)
            });
        }
    })
</script>
<!--添加到收藏-->
<script>
    function addcoll(commodityId) {
        var ok = window.confirm("确定要添加该商品到收藏吗")
        if (ok) {
            $.get("user/finduser", {}, function (data) {
                if (data.length > 0) {
                    var user = data;
                    $.ajax({
                        url: "/shoppingcart/addtocoll",
                        dataType: "json",
                        data: "userId=" + user + "&commodityId=" + commodityId,
                        success: function (data) {
                            alert(data.message)
                        }
                    })
                } else {
                    location.href = "error/403.html"
                }
            });
        }
    }
</script>
<!--添加到购物车-->
<script>
    function addcart(commodityId) {
        var ok = window.confirm("确定要添加该商品到购物车吗")
        if (ok) {
            $.get("user/finduser", {}, function (data) {
                if (data.length > 0) {
                    var user = data;
                    $.ajax({
                        url: "/collection/addtoshopcart",
                        dataType: "json",
                        data: "userId=" + user + "&commodityId=" + commodityId,
                        success: function (data) {
                            alert(data.message)
                        }
                    })
                } else {
                    location.href = "error/403.html"
                }
            });
        }
    }
</script>
</html>